﻿using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using API;
using CoreGraphics;
using Foundation;
using Masonry;
using MyExtensions;

using UIKit;
using Xamarin.Essentials;
using Xamarin.Forms;

namespace mb.iOS
{
    public class VCMyNavigation : UINavigationController
    {
        static ILog logger = mb.ServiceLocator.Instance.Get<ILog>();
        static IStartOption startOption = ServiceLocator.Instance.Get<IStartOption>();

        public bool EnableRotation = false;

        public VCMyNavigation(UIViewController start) : base(start)
        {
            NavigationBarHidden = true;

        }
        public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
        {
            if (EnableRotation)
                return UIInterfaceOrientationMask.All;
            else
                return UIInterfaceOrientationMask.Portrait;
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
        }

        // public override void ViewWillDisappear(bool animated)
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            var toph = TopLayoutGuide.Length;
            var size = UIScreen.MainScreen.Bounds.Size;
            logger.Log("toplayout", toph);
            // View.Frame = new CGRect(0, toph, size.Width, size.Height - toph);
            // View.MakeConstraints(m =>
            // {
            //     m.Top.EqualTo(this.TopLayoutGuideBottom());
            //     m.Bottom.EqualTo(this.BottomLayoutGuideTop());
            //     m.Left.EqualTo(NSObject.FromObject(0));
            //     m.Width.EqualTo(NSObject.FromObject(200));
            // });
        }
    }
}